<include file="Public/min-header"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <!-- Content Header (Page header) -->
    <include file="Public/breadcrumb"/>
    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 订单列表</h3>
                </div>
				<span style="color: red;margin-left: 25px;">已经出库的单，禁止删除！请做退货单。</span>
                <div class="panel-body">
                    <div class="navbar navbar-default">
                            <form action="#" id="search-form2" class="navbar-form form-inline" method="post">
<!--                                <div class="form-group">
                                    <label class="control-label" for="input-order-id">店铺</label>
                                    <div class="input-group">
                                        <input type="text" name="store_name" placeholder="店铺名称" id="input-store-id" class="input-sm" style="width:100px;">
                                    </div>
                                </div>  -->
<!-- 								<?php
								if(session('fenbu_id')==0){
								?>
								<div class="form-group">
								 <select name="fenbu_id" id="fenbu_id" class="input-sm" style="width:120px;">
									<foreach name="fenbu_list" item="v">
									   <option value="{$v['fenbu_id']}">
										{$v['fenbu_name']}
									   </option>
									</foreach>
								</select>
								</div>
								<?php
								}else{
									echo '<input type="hidden" name="fenbu_id" id="fenbu_id" value="'.session('fenbu_id').'" />';
								}
								?> -->
								
								<div class="form-group">
								 <select name="order_type" id="order_type" class="input-sm" style="width:120px;">
								 <option value="0">全部订单</option>
								 <option value="1">线上单</option>
								 <option value="2">代客下单</option>
								 <!-- <option value="3">特殊代客下单</option> -->
								 </select>
								</div>
								<div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="order_sn" id="order_sn" placeholder="订单编号" id="input-order-id" class="input-sm" >
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="pay_master_order_sn" id="pay_master_order_sn" placeholder="线上支付合并单号" id="input-opay_master_order_sn" class="input-sm" >
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="consignee" id="consignee" placeholder="收货人" id="input-member-id" class="input-sm" value="{:I('consignee')}">
                                    </div>
                                </div>
                                
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="mobile" id="mobile" placeholder="客户电话" id="input-member-id" class="input-sm" value="{:I('mobile')}">
                                    </div>
                                </div>
                                
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="company" id="company" placeholder="收货人公司" id="input-member-id" class="input-sm" value="{:I('company')}">
                                    </div>
                                </div>
                                
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="store_name" id="store_name" placeholder="店铺" id="input-member-id" class="input-sm" value="{:I('store_name')}">
                                    </div>
                                </div>


                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="driver" id="driver" placeholder="司机" id="driver" class="input-sm" value="{:I('driver')}">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="biaoshi_xian" id="biaoshi_xian" placeholder="线路" id="biaoshi_xian" class="input-sm" value="{:I('biaoshi_xian')}">
                                    </div>
                                </div>
                                
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="goods_name" id="goods_name" placeholder="商品名称/产品ID" id="input-goods_name-id" class="input-sm" value="{:I('goods_name')}">
                                    </div>
                                </div>
                                
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="timegap" value="{$timegap}" placeholder="下单日期"  id="add_time" class="input-sm" style="width: 220px;">
					                 </div>
                                </div>
<!--                                <div class="form-group">
                                    <select name="pay_status" class="input-sm" style="width:100px;">
                                            <option value="">支付状态</option>
                                            <option value="0">未支付</option>
                  		            <option value="1">已支付</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <select name="pay_code" class="input-sm" style="width:100px;">
                                        	<option value="">支付方式</option>
                                            <option value="alipay">支付宝支付</option>
                  							<option value="weixin">微信支付</option>
                  							<option value="cod">货到付款</option>
                                    </select>
                                </div> -->
<!--                                <div class="form-group">
                                    <select name="shipping_status" class="input-sm" style="width:100px;">
                                        	<option value="">发货状态</option>
                                            <option value="0">未发货</option>
                  							<option value="1">已发货</option>
                  							<option value="2">部分发货</option>
                                    </select>
                                </div> -->
                                <div class="form-group">
                                    <select name="order_status" id="order_status" class="input-sm" style="width:100px;">
                                        <option value="">订单状态</option>
                                        <volist name="order_status" id="v" key="k">
                                            <option value="{$k-1}">{$v}</option>
                                        </volist>
                                    </select>
                                    <input type="hidden" name="order_by" value="order_id">
                                    <input type="hidden" name="sort" value="desc">
                                    <input type="hidden" name="user_id" value="{$_GET[user_id]}">
                                </div>
                                <div class="form-group">
                                    <select name="ku_status"  id="ku_status" class="input-sm" style="width:120px;">
                                        <option value="0">入库状态</option>
                                        <option value="1">未入库</option>
                                        <option value="2">已入库</option>
                                        <option value="3">已出库</option>
                                        <!-- <option value="3">特殊代客下单</option> -->
                                    </select>
                                </div>
                                <div class="form-group">
                                    <select name="pda_qdzt"  id="pda_qdzt" class="input-sm" style="width:120px;">
                                        <option value="0">物流状态</option>
                                        <option value="1">无货</option>
                                        <option value="2">次日送</option>
                                        <!-- <option value="3">特殊代客下单</option> -->
                                    </select>
                                </div>
                                <div class="form-group">
                                	<a href="javascript:void(0)" onclick="ajax_get_table('search-form2',1)" id="button-filter search-order" class="btn btn-primary"><i class="fa fa-search"></i> 筛选</a>
                                </div>
                                <!--
                                <div class="form-group">
                                	<a href="/index.php?m=Admin&c=Order&a=add_order" class="btn btn-primary"><i class="fa fa-search"></i>添加订单</a>
                                </div>
                                -->
                                <button type="button" class="btn btn-default pull-right" id="export_order_goods"><i class="fa fa-file-excel-o"></i>&nbsp;导出订单商品excel</button>
                                <button type="button" class="btn btn-default pull-right" id="daochu"><i class="fa fa-file-excel-o"></i>&nbsp;导出excel</button>
                            </form>
                    </div>
                    <div id="ajax_return">

                    </div>

                </div>
            </div>
        </div>        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->
<script>
    $(document).ready(function(){
        ajax_get_table('search-form2',1);
        
		$('#add_time').daterangepicker({
			format:"YYYY-MM-DD HH:mm",
			singleDatePicker: false,
			showDropdowns: true,
			minDate:'2021-01-01 00:00',
			maxDate:'2030-01-01 00:00',
			startDate:'{:date("Y-m-d")} 00:00',
	        showWeekNumbers: true,
	        timePicker: true,
	        timePickerIncrement: 1,
	        timePicker12Hour: false,
	        opens: 'right',
	        buttonClasses: ['btn btn-default'],
	        applyClass: 'btn-small btn-primary',
	        cancelClass: 'btn-small',
		    locale : {
	            applyLabel : '确定',
	            cancelLabel : '取消',
	            fromLabel : '起始时间',
	            toLabel : '结束时间',
	            customRangeLabel : '自定义',
	            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
	            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
	            firstDay : 1
	        }
		});
		
    });

	$("input[name=order_sn],input[name=consignee]").keydown(function(e){
		if (e.keyCode == "13") {
			ajax_get_table('search-form2',1);
		};
	});

	$("#daochu").click(function(){
		var order_sn=$("#order_sn").val();
		var consignee=$("#consignee").val();
		var company=$("#company").val();
		var store_name=$("#store_name").val();
		var mobile=$("#mobile").val();
		var add_time=$("#add_time").val();
		var order_type=$("#order_type").val();
		var fenbu_id=$("#fenbu_id").val();
		var order_status=$("#order_status").val();
		var biaoshi_xian=$("#biaoshi_xian").val();
		var driver=$("#driver").val();
		var goods_name=$("#goods_name").val();
		var pda_qdzt=$("#pda_qdzt").val();
		location.href="/index.php/Admin/order/export_order?order_sn="+order_sn+"&consignee="+consignee+"&timegap="+add_time+"&order_status="+order_status+"&order_type="+order_type+"&biaoshi_xian="+biaoshi_xian+"&driver="+driver+"&goods_name="+goods_name+"&pda_qdzt="+pda_qdzt+"&company="+company+"&store_name="+store_name+"&mobile="+mobile;
	})
    $('#export_order_goods').click(function() {
        var order_sn = $("#order_sn").val();
        var consignee = $("#consignee").val();
        var company = $("#company").val();
        var store_name = $("#store_name").val();
        var mobile = $("#mobile").val();
        var add_time = $("#add_time").val();
        var order_type = $("#order_type").val();
        var fenbu_id = $("#fenbu_id").val();
        var order_status = $("#order_status").val();
        var biaoshi_xian = $("#biaoshi_xian").val();
        var driver = $("#driver").val();
        var goods_name = $("#goods_name").val();
        var pda_qdzt = $("#pda_qdzt").val();
        location.href = "/index.php/Admin/order/export_order_goods?order_sn=" + order_sn + "&consignee=" + consignee + "&timegap=" + add_time + "&order_status=" + order_status + "&order_type=" + order_type + "&biaoshi_xian=" + biaoshi_xian + "&driver=" + driver + "&goods_name=" + goods_name + "&pda_qdzt=" + pda_qdzt + "&company=" + company + "&store_name=" + store_name + "&mobile=" + mobile;
    });

        // ajax 抓取页面
    function ajax_get_table(tab,page){
        layer.load()
        cur_page = page; //当前页面 保存为全局变量
            $.ajax({
                type : "POST",
                url:"/index.php/Admin/order/ajaxindex/p/"+page,//+tab,
                data : $('#'+tab).serialize(),// 你的formid
                success: function(data){
                    layer.closeAll('loading');
                    try {
                        let json = JSON.parse(data);
                        if(json && json.code == 0){
                            layer.msg(json.msg, {icon: 0});
                            return
                        }
                    }catch (e){
                        $("#ajax_return").html('');
                        $("#ajax_return").append(data);
                    }
                }
            });
    }

    // 点击排序
    function sort(field)
    {
        $("input[name='order_by']").val(field);
        var v = $("input[name='sort']").val() == 'desc' ? 'asc' : 'desc';
        $("input[name='sort']").val(v);
        ajax_get_table('search-form2',cur_page);
    }
</script>
</body>
</html>